package com.telecom.cms.actions;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 * @author yueyingnishang
 * 
 */
public class ImportAction extends Action {

	/**
	 * @param args
	 */

	// public static void main(String[] args) {
	// // TODO Auto-generated method stub
	// HSSFWorkbook wb = new HSSFWorkbook();
	//
	// HSSFSheet sheet = wb.createSheet("查询结果");
	//
	// HSSFRow r = sheet.createRow((short) 0);
	//
	// r.createCell((short) 0).setCellValue(1.2);
	//
	// r.createCell((short) 1).setCellValue("This is a String");
	//
	// r.createCell((short) 2).setCellValue(true);
	//
	// FileOutputStream fileOut;
	// try {
	// fileOut = new FileOutputStream("E://workbook.xls");
	// wb.write(fileOut);
	// fileOut.close();
	// } catch (FileNotFoundException e) {
	// // TODO Auto-generated catch block
	// e.printStackTrace();
	// }
	//
	// catch (IOException e) {
	// // TODO Auto-generated catch block
	// e.printStackTrace();
	// }
	//
	// }
	/*
	 * (non-Javadoc)
	 * 
	 * @see org.apache.struts.action.Action#execute(org.apache.struts.action.ActionMapping,
	 *      org.apache.struts.action.ActionForm,
	 *      javax.servlet.http.HttpServletRequest,
	 *      javax.servlet.http.HttpServletResponse)
	 */
	@Override
	public ActionForward execute(ActionMapping arg0, ActionForm arg1,
			HttpServletRequest arg2, HttpServletResponse arg3) throws Exception {
		// TODO Auto-generated method stub
		HSSFWorkbook wb = new HSSFWorkbook();

		HSSFSheet sheet = wb.createSheet("查询结果");

		HSSFRow r = sheet.createRow((short) 0);

		r.createCell((short) 0).setCellValue(1.2);

		r.createCell((short) 1).setCellValue("This is a String");

		r.createCell((short) 2).setCellValue(true);

		FileOutputStream fileOut;
		try {
			fileOut = new FileOutputStream("E://workbook.xls");
			wb.write(fileOut);
			fileOut.close();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return null;
	}

}
